package com.woniu.dao;

import com.woniu.dto.DynamicCommentDTO;
import com.woniu.pojo.DynamicTags;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface DynamicTagsMapper {
    int deleteByPrimaryKey(Long id);

    int insert(DynamicTags record);

    int insertSelective(DynamicTags record);

    DynamicTags selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(DynamicTags record);

    int updateByPrimaryKey(DynamicTags record);
   @Select("select user_name from users u,dynamic_tags d where d.user_id=u.id and d.dynamic_id=#{id}")
    List<String> selectPersons(Long id);
    @Select("select count(user_name) from users u,dynamic_tags d where d.user_id=u.id and d.dynamic_id=#{id}")
    Integer selectPersonNum(Long id);
@Select("select * from dynamic_comments c,users u where c.user_id=u.id and c.dynamic_id=#{id} order by c.create_time desc")
    List<DynamicCommentDTO> selectComment(Long id);
@Select("select * from dynamic_tags where dynamic_id=#{id}")
    List<DynamicTags> selectByDynamicId(Long id);
@Delete("delete from dynamic_tags where user_id=#{userId} and dynamic_id=#{dynamicId}")
    void deleteTag(@Param("dynamicId") Long dynamicId,@Param("userId") Long userId);
@Select("select count(user_id) from dynamic_tags where dynamic_id=#{dynamicId}")
    Integer selectTagNum(Long dynamicId);


}